$(document).ready(function() {
    $.getJSON('controller/cont.portal.php', {logged: true}, function(data) {
        $('#nip').html(data.nip + ' - ' + data.nama);
        $('#jabatan').html(getString(data.jabatan)[0]);
        $('#unit').html(getString(data.jabatan)[1]);
    });

    //getKewenangan();
    $.getJSON('controller/cont.tanggal.php', {tanggal: true}, function(data) {
        document.getElementById('tanggal').innerHTML = data;
    });

    $.getJSON('controller/cont.login.php',{aksi_menu:true},function(data){
        if(data){
            document.getElementById("pic").style.display='block';
            document.getElementById("pic2").style.display='block';
            document.getElementById("pic3").style.display='block';
        }else{
            document.getElementById("pic").style.display="none";
            document.getElementById("pic2").style.display="none";
            document.getElementById("pic3").style.display="none";
        }
    });

    return false;
});

function getString(str) {
    var jabat = str.split("\n");
    return jabat;
}

function getKewenangan() {
    $.getJSON('controller/cont.ruh.php', {aksi_get_all_kewenangan: true}, function(data) {
        $.each(data, function(index, data) {
            var option2 = $('<option />');
            option2.attr('value', data.id_kewenangan).text(data.nama_kewenangan);
            $('#kewenangan').append(option2);
        });
    });
}

function getAllKanwil() {
    $.getJSON('controller/cont.kanwil.php', {aksi_get_all_kanwil: true}, function(data) {
        $.each(data, function(index, data) {
            var option = $('<option />');
            option.attr('value', data.kdkanwil).text(data.nmkanwil);
            $('#kanwil').append(option);
        });
    });
}

function getKanwil() {
    $.getJSON('controller/cont.kanwil.php', {aksi_get_kanwil: true}, function(data) {
        var option = $('<option />');
        option.attr('value', data.kdkanwil).text(data.nmkanwil);
        $('#kanwil').append(option);
    });
}